import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import BaseBasicLayout from '@/packages/layout/baseBasicLayout/baseBasicLayout.vue'
// 路由
import RouteView from '@/packages/layout/routeView.vue'
Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
    {
        path: '/',
        name: 'baseBasicLayout',
        component: BaseBasicLayout,
        meta: {
            title: '首页'
        },
        redirect: '/workplace',
        children: [
            {
                path: '/workplace',
                name: 'workplace',
                component: () => import('@/views/Home.vue'),
                meta: {
                    title: '工作台',
                    hiddenHeaderContent: true
                }
            },
            {
                path: '/preview',
                name: 'preview',
                component: () => import('@/views/preview.vue'),
                meta: {
                    title: '图片预览'
                }
            },
            {
                path: '/editor',
                name: 'editor',
                component: () => import('@/views/editor.vue'),
                meta: {
                    title: '富文本编辑器'
                }
            },
            {
                path: '/tabAndInfo',
                name: 'tabAndInfo',
                component: RouteView,
                meta: { title: '表格+详情页', merge: true },
                redirect: '/data/table',
                children: [
                    {
                        path: '/data/table',
                        name: 'data_table',
                        component: () => import('@/views/table/index.vue'),
                        meta: {
                            title: '表格列表'
                        }
                    },
                    {
                        path: '/data/info',
                        name: 'data_info',
                        component: () => import('@/views/table/info.vue'),
                        meta: {
                            title: '表格详情'
                        }
                    }
                ]
            },
            {
                path: '/page',
                name: 'page',
                component: RouteView,
                meta: { title: '页面' },
                redirect: '/data/table',
                children: [
                    {
                        path: '/page/lock',
                        name: 'page_lock',
                        component: () => import('@/views/lock/lock.vue'),
                        meta: {
                            title: '加锁'
                        }
                    },
                    {
                        path: '/data/unlock',
                        name: 'data_unlock',
                        component: () => import('@/views/lock/unlock.vue'),
                        meta: {
                            title: '解锁'
                        }
                    }
                ]
            },
            {
                path: '/card',
                name: 'card',
                component: () => import('@/views/card.vue'),
                meta: { title: '卡片' },
            }
        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export { routes }
export default router
